home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 003 / _gs / !GS / h / DICT < prev    next >
Text File  |  1991-10-25  |  3KB  |  83 lines

  1. /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* dict.h */
  21. /* Interfaces for Ghostscript dictionary package */
  22.  
  23. /* Define the maximum size of a dictionary */
  24. extern uint dict_max_size;
  25.  
  26. /* Create a dictionary */
  27. extern int dict_create(P2(uint maxlength, ref *dict));
  28.  
  29. /* Return a pointer to a ref that holds the access attributes */
  30. /* for a dictionary. */
  31. extern ref *dict_access_ref(P1(ref *dict));
  32. #define check_dict_read(dict) check_read(*dict_access_ref(&dict))
  33. #define check_dict_write(dict) check_write(*dict_access_ref(&dict))
  34.  
  35. /* Look up in a stack of dictionaries.  Store a pointer to the value slot */
  36. /* where found, or to the (value) slot for inserting. */
  37. /* Return 1 if found, 0 if not and there is room for a new entry, */
  38. /* or e_dictfull if the dictionary is full and the key is missing. */
  39. /* The caller is responsible for ensuring key is not a null. */
  40. /* Note that pdbot <= pdtop, and the search starts at pdtop. */
  41. extern int dict_lookup(P4(ref *pdbot, ref *pdtop, ref *key, ref **ppvalue));
  42. /* Look up in just one dictionary. */
  43. #define dict_find(dict,key,ppvalue) dict_lookup(dict,dict,key,ppvalue)
  44.  
  45. /* Enter a key-value pair in a dictionary. */
  46. /* Return 0, e_dictfull, or e_VMerror if the key was a string */
  47. /* and a VMerror occurred when converting it to a name. */
  48. extern int dict_put(P3(ref *dict, ref *key, ref *pvalue));
  49.  
  50. /* Remove a key-value pair from a dictionary. */
  51. /* Return 0 or e_undefined. */
  52. extern int dict_undef(P2(ref *dict, ref *key));
  53.  
  54. /* Return the number of elements in a dictionary. */
  55. extern uint dict_length(P1(ref *dict));
  56.  
  57. /* Return the capacity of a dictionary. */
  58. extern uint dict_maxlength(P1(ref *dict));
  59.  
  60. /* Copy one dictionary into another. */
  61. /* Return 0 or e_dictfull. */
  62. extern int dict_copy(P2(ref *dfrom, ref *dto));
  63.  
  64. /* Grow or shrink a dictionary. */
  65. /* Return 0 or e_dictfull. */
  66. extern int dict_resize(P2(ref *dict, uint newmaxlength));
  67.  
  68. /* Prepare to enumerate a dictionary. */
  69. /* Return an integer suitable for the first call to dict_next. */
  70. extern int dict_first(P1(ref *dict));
  71.  
  72. /* Enumerate the next element of a dictionary. */
  73. /* index is initially the result of a call on dict_first. */
  74. /* Either store a key and value at eltp[0] and eltp[1] */
  75. /* and return an updated index, or return -1 */
  76. /* to signal that there are no more elements in the dictionary. */
  77. extern int dict_next(P3(ref *dict, int index, ref *eltp));
  78.  
  79. /* Define the dictionary stack and the standard dictionaries. */
  80. extern ref dstack[];
  81. #define systemdict (dstack[0])
  82. #define userdict (dstack[1])
  83.